home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / games / IndiZone / gold / bubClass.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  12.0 KB  |  393 lines

  1. /*
  2.  * The original copyright owners of the accompanying source code files have
  3.  * agreed to place such code into the public domain.  Accordingly, anyone
  4.  * who receives or obtains a copy of such source code is freely entitled to
  5.  * reproduce, use and otherwise exploit such code (including the right to
  6.  * make derivative works), at his/her own risk and expense, without any
  7.  * obligation or liability to the original copyright owners.
  8.  *
  9.  * We would appreciate (but do not require) that the following message be
  10.  * included in any derivative works:
  11.  *
  12.  * "Portions of this program were developed by Peter Broadwell, Rob Myers
  13.  * and Robin Schaufler while working in Silicon Valley."
  14.  *
  15.  * The accompanying source code files and related documentation materials
  16.  * are distributed on an "AS IS" basis, without any warranties or
  17.  * guarantees of any kind.  All implied warranties, including the implied
  18.  * warranties of merchantability and of fitness for any particular purpose,
  19.  * are expressly disclaimed.
  20.  */
  21. #include "gl.h"
  22. #include "geom.h"
  23. #include "selectors.h"
  24. #include "class.h"
  25. #include "classIds.h"
  26. #include "mbox.h"
  27. #include "individual.h"
  28. #include "behavior.h"
  29. #include "doers.h"
  30. #include "bub.h"
  31.  
  32. #include "colors.h"
  33.  
  34. extern class indivClass;
  35. model bubbleModel;
  36. model wigglerBubModel;
  37. model feederBubModel;
  38. model colorBubModel;
  39. model femaleBubModel;
  40. model maleBubModel;
  41.  
  42. extern behavior wigglerTemplate;
  43. extern behavior colorizerTemplate;
  44. extern behavior feederTemplate;
  45. extern behavior femaleTemplate;
  46. extern behavior maleTemplate;
  47.  
  48. extern char *bubbleinit();
  49. extern char *bubblefree();
  50. extern char *selectBub();
  51.  
  52. fcnTable bubbleTable[] = {
  53.     INIT,    bubbleinit,    /* build bubble drawing */
  54.     FREE,    bubblefree,
  55.     SELECT,    selectBub,    /* post the behavior held by picked bubble */
  56.     POSTBEHAVE,    NULL,        /* should never be posted of a behavior */
  57.     EOTABLE,
  58. };
  59.  
  60. class bubbleClass = {
  61.     &indivClass,
  62.     bubbleTable,
  63.     sizeof(bubble),
  64.     BUBBLE,
  65. };
  66.  
  67. bubble bubbleTemplate = {
  68.             /*   inst        */
  69.     &bubbleClass,    /* myClass pointer    */
  70.     NULL,        /* classFunctions     */
  71.     0,            /* nFunctions        */
  72.             /*   mailbox        */
  73.     NULL,        /* subscribers          */
  74.     NULL,        /* subscribedTo         */
  75.             /*   individual        */
  76.     {0,0,0},        /* position        */
  77.     {0,0,0},        /* lastPosition        */
  78.     {1,0,0},        /* delta        */
  79.     {0,0,300},        /* velocity        */
  80.     {0,0,300},        /* avelocity        */
  81.     {0,0,0},        /* acceleration        */
  82.     1.0,        /* speed        */
  83.     {0,0,10},        /* heading        */
  84.     {0,0,0},        /* rotation        */
  85.     {0,0,0},        /* influence        */
  86.     1.0,        /* scale                */
  87.     &bubbleModel,    /* model        */
  88.     NULL,        /* flags        */
  89.     NULL,        /* curVars              */
  90.             /*   bubble        */
  91.     NULL,        /* doer                 */
  92. };
  93.  
  94. model bubbleModel = {
  95.     NULL,            /* next model segment          */
  96.     NULL,            /* child model segments        */
  97.     0,                /* geometry compiled yet?      */
  98.     0,                /* compiled geometry object Id */
  99.     NULL,            /* point dictionary            */
  100.     NULL,            /* polygon descriptions        */
  101.     {0 ,0, 0},            /* centroid                    */
  102.     BUBBLE_COLOR,        /* color                       */
  103.     BUBBLE_TEXTURE,        /* texture                     */
  104.     TRUE,            /* outlined                    */
  105.     { 0,0,0},            /* rotation                    */
  106.     { 0,0,0},            /* translation                 */
  107.     { 1.0,1.0,1.0},        /* scale                       */
  108.     20,                /* declasse               */
  109. };
  110.  
  111. bubble wigglerBub = {
  112.             /*   inst        */
  113.     &bubbleClass,    /* myClass pointer    */
  114.     NULL,        /* classFunctions     */
  115.     0,            /* nFunctions        */
  116.             /*   mailbox        */
  117.     NULL,        /* subscribers          */
  118.     NULL,        /* subscribedTo         */
  119.             /*   individual        */
  120.     {0,0,0},        /* position        */
  121.     {0,0,0},        /* lastPosition        */
  122.     {1,0,0},        /* delta        */
  123.     {0,0,300},        /* velocity        */
  124.     {0,0,300},        /* avelocity        */
  125.     {0,0,0},        /* acceleration        */
  126.     1.0,        /* speed        */
  127.     {0,0,10},        /* heading        */
  128.     {0,0,0},        /* rotation        */
  129.     {0,0,0},        /* influence        */
  130.     1.0,        /* scale                */
  131.     &wigglerBubModel,    /* model        */
  132.     NULL,        /* flags        */
  133.     NULL,        /* curVars              */
  134.     NULL,        /* controls             */
  135.             /*   bubble        */
  136.     &wigglerTemplate,    /* doer                 */
  137. };
  138.  
  139. model wigglerBubModel = {
  140.     NULL,            /* next model segment          */
  141.     NULL,            /* child model segments        */
  142.     0,                /* geometry compiled yet?      */
  143.     0,                /* compiled geometry object Id */
  144.     NULL,            /* point dictionary            */
  145.     NULL,            /* polygon descriptions        */
  146.     {0 ,0, 0},            /* centroid                    */
  147.     WIGGLER_COLOR,        /* color                       */
  148.     BUBBLE_TEXTURE,        /* texture                     */
  149.     TRUE,            /* outlined                    */
  150.     { 0,0,0},            /* rotation                    */
  151.     { 0,0,0},            /* translation                 */
  152.     { 1.0,1.0,1.0},        /* scale                       */
  153.     20,                /* declasse               */
  154. };
  155.  
  156. bubble feederBub = {
  157.             /*   inst        */
  158.     &bubbleClass,    /* myClass pointer    */
  159.     NULL,        /* classFunctions     */
  160.     0,            /* nFunctions        */
  161.             /*   mailbox        */
  162.     NULL,        /* subscribers          */
  163.     NULL,        /* subscribedTo         */
  164.             /*   individual        */
  165.     {0,0,0},        /* position        */
  166.     {0,0,0},        /* lastPosition        */
  167.     {1,0,0},        /* delta        */
  168.     {0,0,300},        /* velocity        */
  169.     {0,0,300},        /* avelocity        */
  170.     {0,0,0},        /* acceleration        */
  171.     1.0,        /* speed        */
  172.     {0,0,10},        /* heading        */
  173.     {0,0,0},        /* rotation        */
  174.     {0,0,0},        /* influence        */
  175.     1.0,        /* scale                */
  176.     &feederBubModel,    /* model        */
  177.     NULL,        /* flags        */
  178.     NULL,        /* curVars              */
  179.     NULL,        /* controls             */
  180.             /*   bubble        */
  181.     &feederTemplate,    /* doer                 */
  182. };
  183.  
  184. model feederBubModel = {
  185.     NULL,            /* next model segment          */
  186.     NULL,            /* child model segments        */
  187.     0,                /* geometry compiled yet?      */
  188.     0,                /* compiled geometry object Id */
  189.     NULL,            /* point dictionary            */
  190.     NULL,            /* polygon descriptions        */
  191.     {0 ,0, 0},            /* centroid                    */
  192.     FEEDER_COLOR,        /* color                       */
  193.     BUBBLE_TEXTURE,        /* texture                     */
  194.     TRUE,            /* outlined                    */
  195.     { 0,0,0},            /* rotation                    */
  196.     { 0,0,0},            /* translation                 */
  197.     { 1.0,1.0,1.0},        /* scale                       */
  198.     20,                /* declasse               */
  199. };
  200.  
  201. bubble colorizerBub = {
  202.             /*   inst        */
  203.     &bubbleClass,    /* myClass pointer    */
  204.     NULL,        /* classFunctions     */
  205.     0,            /* nFunctions        */
  206.             /*   mailbox        */
  207.     NULL,        /* subscribers          */
  208.     NULL,        /* subscribedTo         */
  209.             /*   individual        */
  210.     {0,0,0},        /* position        */
  211.     {0,0,0},        /* lastPosition        */
  212.     {1,0,0},        /* delta        */
  213.     {0,0,300},        /* velocity        */
  214.     {0,0,300},        /* avelocity        */
  215.     {0,0,0},        /* acceleration        */
  216.     1.0,        /* speed        */
  217.     {0,0,10},        /* heading        */
  218.     {0,0,0},        /* rotation        */
  219.     {0,0,0},        /* influence        */
  220.     1.0,        /* scale                */
  221.     &colorBubModel,    /* model        */
  222.     NULL,        /* flags        */
  223.     NULL,        /* curVars              */
  224.     NULL,        /* controls             */
  225.             /*   bubble        */
  226.     &colorizerTemplate,    /* doer                 */
  227. };
  228.  
  229. model colorBubModel = {
  230.     NULL,            /* next model segment          */
  231.     NULL,            /* child model segments        */
  232.     0,                /* geometry compiled yet?      */
  233.     0,                /* compiled geometry object Id */
  234.     NULL,            /* point dictionary            */
  235.     NULL,            /* polygon descriptions        */
  236.     {0 ,0, 0},            /* centroid                    */
  237.     COLORIZER_COLOR,        /* color                       */
  238.     BUBBLE_TEXTURE,        /* texture                     */
  239.     TRUE,            /* outlined                    */
  240.     { 0,0,0},            /* rotation                    */
  241.     { 0,0,0},            /* translation                 */
  242.     { 1.0,1.0,1.0},        /* scale                       */
  243.     20,                /* declasse               */
  244. };
  245.  
  246. bubble femaleBub = {
  247.             /*   inst        */
  248.     &bubbleClass,    /* myClass pointer    */
  249.     NULL,        /* classFunctions     */
  250.     0,            /* nFunctions        */
  251.             /*   mailbox        */
  252.     NULL,        /* subscribers          */
  253.     NULL,        /* subscribedTo         */
  254.             /*   individual        */
  255.     {0,0,0},        /* position        */
  256.     {0,0,0},        /* lastPosition        */
  257.     {1,0,0},        /* delta        */
  258.     {0,0,300},        /* velocity        */
  259.     {0,0,300},        /* avelocity        */
  260.     {0,0,0},        /* acceleration        */
  261.     1.0,        /* speed        */
  262.     {0,0,10},        /* heading        */
  263.     {0,0,0},        /* rotation        */
  264.     {0,0,0},        /* influence        */
  265.     1.0,        /* scale                */
  266.     &femaleBubModel,    /* model        */
  267.     NULL,        /* flags        */
  268.     NULL,        /* curVars              */
  269.     NULL,        /* controls             */
  270.             /*   bubble        */
  271.     &femaleTemplate,    /* doer                 */
  272. };
  273.  
  274. model femaleBubModel = {
  275.     NULL,            /* next model segment          */
  276.     NULL,            /* child model segments        */
  277.     0,                /* geometry compiled yet?      */
  278.     0,                /* compiled geometry object Id */
  279.     NULL,            /* point dictionary            */
  280.     NULL,            /* polygon descriptions        */
  281.     {0 ,0, 0},            /* centroid                    */
  282.     FEMALE_COLOR,        /* color                       */
  283.     BUBBLE_TEXTURE,        /* texture                     */
  284.     TRUE,            /* outlined                    */
  285.     { 0,0,0},            /* rotation                    */
  286.     { 0,0,0},            /* translation                 */
  287.     { 1.0,1.0,1.0},        /* scale                       */
  288.     20,                /* declasse               */
  289. };
  290.  
  291. bubble maleBub = {
  292.             /*   inst        */
  293.     &bubbleClass,    /* myClass pointer    */
  294.     NULL,        /* classFunctions     */
  295.     0,            /* nFunctions        */
  296.             /*   mailbox        */
  297.     NULL,        /* subscribers          */
  298.     NULL,        /* subscribedTo         */
  299.             /*   individual        */
  300.     {0,0,0},        /* position        */
  301.     {0,0,0},        /* lastPosition        */
  302.     {1,0,0},        /* delta        */
  303.     {0,0,300},        /* velocity        */
  304.     {0,0,300},        /* avelocity        */
  305.     {0,0,0},        /* acceleration        */
  306.     1.0,        /* speed        */
  307.     {0,0,10},        /* heading        */
  308.     {0,0,0},        /* rotation        */
  309.     {0,0,0},        /* influence        */
  310.     1.0,        /* scale                */
  311.     &maleBubModel,    /* model        */
  312.     NULL,        /* flags        */
  313.     NULL,        /* curVars              */
  314.     NULL,        /* controls             */
  315.             /*   bubble        */
  316.     &maleTemplate,    /* doer                 */
  317. };
  318.  
  319. model maleBubModel = {
  320.     NULL,            /* next model segment          */
  321.     NULL,            /* child model segments        */
  322.     0,                /* geometry compiled yet?      */
  323.     0,                /* compiled geometry object Id */
  324.     NULL,            /* point dictionary            */
  325.     NULL,            /* polygon descriptions        */
  326.     {0 ,0, 0},            /* centroid                    */
  327.     MALE_COLOR,            /* color                       */
  328.     BUBBLE_TEXTURE,        /* texture                     */
  329.     TRUE,            /* outlined                    */
  330.     { 0,0,0},            /* rotation                    */
  331.     { 0,0,0},            /* translation                 */
  332.     { 1.0,1.0,1.0},        /* scale                       */
  333.     20,                /* declasse               */
  334. };
  335.  
  336. extern char *blowInit();
  337. extern char *blowBubble();
  338. extern behavior *doerbubs[];
  339.  
  340. fcnTable bubbleMachineTable[] = {
  341.     INIT,    blowInit,
  342.     DOIT,    blowBubble,
  343.     EOTABLE,
  344. };
  345.  
  346. class bubbleMachineClass = {
  347.     &indivClass,
  348.     bubbleMachineTable,
  349.     sizeof(bubbleMachine),
  350.     BUBBLEMACHINE,
  351. };
  352.  
  353. bubbleMachine bubbleMachineTemplate = {
  354.             /*   inst        */
  355.     &bubbleMachineClass,/* myClass pointer    */
  356.     NULL,        /* classFunctions     */
  357.     0,            /* nFunctions        */
  358.             /*   mailbox        */
  359.     NULL,        /* subscribers          */
  360.     NULL,        /* subscribedTo         */
  361.             /*   individual        */
  362.     {500,100,-5000},    /* position        */
  363.     {0,0,0},        /* lastPosition        */
  364.     {1,0,0},        /* delta        */
  365.     {0,0,0},        /* velocity        */
  366.     {0,0,0},        /* avelocity        */
  367.     {0,0,0},        /* acceleration        */
  368.     1.0,        /* speed        */
  369.     {0,0,10},        /* heading        */
  370.     {0,0,0},        /* rotation        */
  371.     {0,0,0},        /* influence        */
  372.     1.0,        /* scale                */
  373.     NULL,        /* model        */
  374.     NULL,        /* flags        */
  375.     NULL,        /* curVars              */
  376.     NULL,        /* controls             */
  377.             /*   bubbleMachine      */
  378.     0,            /* bubbleClock          */
  379.     5,            /* bubbleDispatchIncr   */
  380.     3,            /* bubbleSpeedupIncr    */
  381.     0,            /* bubbleDoer        */
  382.     doerbubs,        /* doers        */
  383. };
  384.  
  385. behavior *doerbubs[] = {
  386.     &feederTemplate,
  387.     &colorizerTemplate,
  388.     &femaleTemplate,
  389.     &maleTemplate,
  390.     &wigglerTemplate,
  391.     NULL,
  392. };
  393.